package com.banciyuan.bcywebview.base.view.other;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import com.banciyuan.bcywebview.R;

/**
 * Created by squall on 2016/9/9.
 */
public class LeftBubleShape extends View {

    private Paint paint;
    private Path path;

    public LeftBubleShape(Context context) {
        super(context);
        initPaint();
    }

    public LeftBubleShape(Context context, AttributeSet attrs) {
        super(context, attrs);
        initPaint();
    }

    public LeftBubleShape(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initPaint();
    }

    public LeftBubleShape(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initPaint();
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int w = getWidth();
        path.moveTo(w, 0);
        path.lineTo(w, w);
        path.lineTo(w / 3, w / 2);
        path.lineTo(w, 0);
        path.close();

        canvas.drawPath(path, paint);
    }

    private void initPaint() {
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(getResources().getColor(R.color.white));

        path = new Path();
    }
}
